/**
 * 活动管理
 */
import request from '/@/utils/request';

export function readAllActivity(params?: any) {
  return request({
    url: 'activities',
    method: 'get',
    params,
  });
}

export function readOneActivity(id: string) {
  return request({
    url: `activities/${id}`,
    method: 'get',
  });
}

export function createActivity(data: any) {
  return request({
    url: 'activities',
    method: 'post',
    data,
  });
}

export function updateActivity(id: string, data: any) {
  return request({
    url: `activities/${id}`,
    method: 'patch',
    data,
  });
}

export function setOnline(id: string, data?: any) {
  return request({
    url: `activities/${id}/set-online`,
    method: 'post',
    data,
  });
}

export function setOffline(id: string, data?: any) {
  return request({
    url: `activities/${id}/set-offline`,
    method: 'post',
    data,
  });
}

export function deleteActivity(id: string) {
  return request({
    url: `activities/${id}`,
    method: 'delete',
  });
}

export function getActivityItems(id: string) {
  return request({
    url: `activities/${id}/items`,
    method: 'get',
  });
}

export function addPhoto(id: string, data: any) {
  return request({
    url: `activities/${id}/photoes`,
    method: 'post',
    data
  });
}

export function deletePhoto(id: string, photo_id: string) {
  return request({
    url: `activities/${id}/photoes/${photo_id}`,
    method: 'delete'
  });
}

export function getPhotoes(id: string, params: any) {
  return request({
    url: `activities/${id}/photoes`,
    method: 'get',
    params
  });
}
